<?php 
class Backend_Topics_Controller extends Backend_Controller_Crud
{
	/**
	 * (non-PHPdoc)
	 * @see Backend_Controller_Crud::indexAction()
	 */
	public function indexAction(){
		parent::indexAction();
		$this->_resource->addJs('/js/app/system/Topics.js', 3);
	}
	/**
	 * List action
	 * Used for comboBox stores
	 */
    public function combolistAction(){
    	$model = Model::factory('topics');
    	$items = $model->getListVc(false,false,false,array('id','title'));
    	Response::jsonSuccess($items);
    }
    /**
     * (non-PHPdoc)
     * @see Backend_Controller_Crud::listAction()
     */
    public function listAction(){
    	$model = Model::factory('topics');
    	$items = $model->getListVc(false,false,false,array('id','title','code','order_no'));
    	Response::jsonSuccess($items);
    }
	/**
     * Check if page code is unique
     */
    public function checkcodeAction(){
        $id = Request::post('id', 'int', 0);
        $code = Request::post('code','string',false);    
        $code = Filter::filterValue('pagecode', $code);
        
        $model = Model_Page::getInstance();
        
        if($model->checkUnique($id , 'code' , $code))
            Response::jsonSuccess(array('code'=>$code));
        else 
            Response::jsonError($this->_lang->SB_UNIQUE);    
    }
}